<p>
  switch语句中每个case语句结尾都要加上一个break。
</p>

<h2>不规范的代码示例</h2>
<pre>
switch (myVariable) {
  case 1:                              
    foo();
    break;
  case 2:  // “ doSomething（）”和“ doSomethingElse（）”都将被执行。
    doSomething();
  default:                               
    doSomethingElse();
    break;
}
</pre>

<h2>正确的代码示例</h2>
<pre>
switch (myVariable) {
  case 1:                              
    foo();
    break;
  case 2: 
    doSomething();
    break;
  default:                               
    doSomethingElse();
    break;
}
</pre>

<h2>例外</h2>
<p>在以下情况下，将放宽此规则:</p>
<pre>
switch (myVariable) {
  case 0:                                // 空案例用于为一组案例指定相同的行为。
  case 1:                               
    doSomething();
    break;
  case 2:                                // Use of return statement
    return;
  case 3:                                // Use of throw statement
    throw new IllegalStateException();
  default:                               // 对于最后一种情况，使用break语句是可选的
    doSomethingElse();
}
</pre>

<h2>更多</h2>
<ul>
  <li>MISRA C:2004, 15.0 - The MISRA C <em>switch</em> syntax shall be used.</li>
  <li>MISRA C:2004, 15.2 - An unconditional break statement shall terminate every non-empty switch clause</li>
  <li>MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.</li>
  <li>MISRA C++:2008, 6-4-5 - An unconditional throw or break statement shall terminate every non-empty switch-clause</li>
  <li>MISRA C:2012, 16.1 - All switch statements shall be well-formed</li>
  <li>MISRA C:2012, 16.3 - An unconditional break statement shall terminate every switch-clause</li>
  <li><a href="http://cwe.mitre.org/data/definitions/484.html">MITRE, CWE-484</a> - Omitted Break Statement in Switch</li>
  <li><a href="https://www.securecoding.cert.org/confluence/x/YIFLAQ">CERT, MSC17-C</a> - Finish every set of statements associated with a case label with a break statement</li>
  <li><a href="https://www.securecoding.cert.org/confluence/x/ZoFLAQ">CERT, MSC18-CPP</a> - Finish every set of statements associated with a case label with a break statement</li>
</ul>
